package com.mediacloud.app.newsmodule.fragment.military

import android.graphics.Color
import android.os.Bundle
import android.view.ViewGroup
import com.bumptech.glide.Glide
import com.bumptech.glide.request.RequestOptions
import com.jaeger.library.StatusBarUtil
import com.mediacloud.app.model.activity.BaseBackActivity
import com.mediacloud.app.model.news.ArticleItem
import com.mediacloud.app.model.news.CatalogItem
import com.mediacloud.app.newsmodule.R
import kotlinx.android.synthetic.main.military_calendar_activity.*
import kotlinx.android.synthetic.main.simple_title_bar_white_tx.*

class MilitaryCalendarActivity : BaseBackActivity() {
    var catalogItem: CatalogItem? = null
    override fun getLayoutResID(): Int {
        return R.layout.military_calendar_activity
    }


    override fun getFitSystemWindow(): Boolean {
        return false
    }

    override fun showTitleBar() = false

    override fun getStatusBarColor() = Color.TRANSPARENT

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        StatusBarUtil.setDarkMode(this)
        backIv.setOnClickListener { finish() }
        val lp = titleLayout.layoutParams as ViewGroup.MarginLayoutParams
        lp.topMargin = StatusBarUtil.getStatusBarHeight(this)
        titleLayout.layoutParams = lp
        catalogItem = intent.getParcelableExtra("catalogItem")
        val background_pic =intent.getStringExtra("background_pic")
        val option = RequestOptions()
        option.error(R.drawable.military_calendar_bg)
        Glide.with(this).load(background_pic).apply(option).into(bgIv)
        val fragment = MilitaryCalendarFragment()
        val b = Bundle()
        b.putParcelable("catalog", catalogItem)
        b.putString("id", "${catalogItem?.catid}")
        val data =intent.getParcelableExtra<ArticleItem>("DATA")
        if(data!=null){
            b.putParcelable("DATA",data)
        }
        fragment.arguments = b
        supportFragmentManager.beginTransaction().add(R.id.container, fragment).commit()
    }
}